{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pywintypes\n",
    "import time\n",
    "import datetime"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "pywintypes.datetime"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "pywintypes.datetime(2019, 5, 9, 7, 41)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "2019"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "5"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "9"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "7"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "41"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2019-05-09 07:41:00\n"
     ]
    }
   ],
   "source": [
    "\n",
    "# create a time object\n",
    "myTime = time.time()\n",
    "\n",
    "# easy way to create a datetime object from 1970 to 1938\n",
    "new_datetime = datetime.datetime.fromtimestamp(int (myTime))\n",
    "\n",
    "# convert it to a Time object in PyWin\n",
    "myTime = pywintypes.Time(myTime)\n",
    "\n",
    "# what is the type\n",
    "display(type(myTime))\n",
    "display(myTime)\n",
    "\n",
    "# display the parts of the pyWin Datetime\n",
    "display(myTime.year)\n",
    "display(myTime.month)\n",
    "display(myTime.day)\n",
    "display(myTime.hour)\n",
    "display(myTime.minute)\n",
    "display(myTime.second)\n",
    "\n",
    "# convert the pyWinType to a normal datetime object\n",
    "new_datetime = datetime.datetime (\n",
    "  year=myTime.year,\n",
    "  month=myTime.month,\n",
    "  day=myTime.day,\n",
    "  hour=myTime.hour,\n",
    "  minute=myTime.minute,\n",
    "  second=myTime.second\n",
    ")\n",
    "print(new_datetime)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on module pywintypes:\n",
      "\n",
      "NAME\n",
      "    pywintypes - Module containing common objects and functions used by various Pywin32 modules\n",
      "\n",
      "CLASSES\n",
      "    builtins.Exception(builtins.BaseException)\n",
      "        com_error\n",
      "        error\n",
      "    datetime.datetime(datetime.date)\n",
      "        datetime\n",
      "    \n",
      "    TimeType = class datetime(datetime.datetime)\n",
      "     |  datetime(year, month, day[, hour[, minute[, second[, microsecond[,tzinfo]]]]])\n",
      "     |  \n",
      "     |  The year, month and day arguments are required. tzinfo may be None, or an\n",
      "     |  instance of a tzinfo subclass. The remaining arguments may be ints.\n",
      "     |  \n",
      "     |  Method resolution order:\n",
      "     |      datetime\n",
      "     |      datetime.datetime\n",
      "     |      datetime.date\n",
      "     |      builtins.object\n",
      "     |  \n",
      "     |  Methods defined here:\n",
      "     |  \n",
      "     |  Format(...)\n",
      "     |  \n",
      "     |  __delattr__(self, name, /)\n",
      "     |      Implement delattr(self, name).\n",
      "     |  \n",
      "     |  __getattribute__(self, name, /)\n",
      "     |      Return getattr(self, name).\n",
      "     |  \n",
      "     |  __setattr__(self, name, value, /)\n",
      "     |      Implement setattr(self, name, value).\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Static methods defined here:\n",
      "     |  \n",
      "     |  __new__(*args, **kwargs) from builtins.type\n",
      "     |      Create and return a new object.  See help(type) for accurate signature.\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Methods inherited from datetime.datetime:\n",
      "     |  \n",
      "     |  __add__(self, value, /)\n",
      "     |      Return self+value.\n",
      "     |  \n",
      "     |  __eq__(self, value, /)\n",
      "     |      Return self==value.\n",
      "     |  \n",
      "     |  __ge__(self, value, /)\n",
      "     |      Return self>=value.\n",
      "     |  \n",
      "     |  __gt__(self, value, /)\n",
      "     |      Return self>value.\n",
      "     |  \n",
      "     |  __hash__(self, /)\n",
      "     |      Return hash(self).\n",
      "     |  \n",
      "     |  __le__(self, value, /)\n",
      "     |      Return self<=value.\n",
      "     |  \n",
      "     |  __lt__(self, value, /)\n",
      "     |      Return self<value.\n",
      "     |  \n",
      "     |  __ne__(self, value, /)\n",
      "     |      Return self!=value.\n",
      "     |  \n",
      "     |  __radd__(self, value, /)\n",
      "     |      Return value+self.\n",
      "     |  \n",
      "     |  __reduce__(...)\n",
      "     |      __reduce__() -> (cls, state)\n",
      "     |  \n",
      "     |  __reduce_ex__(...)\n",
      "     |      __reduce_ex__(proto) -> (cls, state)\n",
      "     |  \n",
      "     |  __repr__(self, /)\n",
      "     |      Return repr(self).\n",
      "     |  \n",
      "     |  __rsub__(self, value, /)\n",
      "     |      Return value-self.\n",
      "     |  \n",
      "     |  __str__(self, /)\n",
      "     |      Return str(self).\n",
      "     |  \n",
      "     |  __sub__(self, value, /)\n",
      "     |      Return self-value.\n",
      "     |  \n",
      "     |  astimezone(...)\n",
      "     |      tz -> convert to local time in new timezone tz\n",
      "     |  \n",
      "     |  ctime(...)\n",
      "     |      Return ctime() style string.\n",
      "     |  \n",
      "     |  date(...)\n",
      "     |      Return date object with same year, month and day.\n",
      "     |  \n",
      "     |  dst(...)\n",
      "     |      Return self.tzinfo.dst(self).\n",
      "     |  \n",
      "     |  isoformat(...)\n",
      "     |      [sep] -> string in ISO 8601 format, YYYY-MM-DDT[HH[:MM[:SS[.mmm[uuu]]]]][+HH:MM].\n",
      "     |      sep is used to separate the year from the time, and defaults to 'T'.\n",
      "     |      timespec specifies what components of the time to include (allowed values are 'auto', 'hours', 'minutes', 'seconds', 'milliseconds', and 'microseconds').\n",
      "     |  \n",
      "     |  replace(...)\n",
      "     |      Return datetime with new specified fields.\n",
      "     |  \n",
      "     |  time(...)\n",
      "     |      Return time object with same time but with tzinfo=None.\n",
      "     |  \n",
      "     |  timestamp(...)\n",
      "     |      Return POSIX timestamp as float.\n",
      "     |  \n",
      "     |  timetuple(...)\n",
      "     |      Return time tuple, compatible with time.localtime().\n",
      "     |  \n",
      "     |  timetz(...)\n",
      "     |      Return time object with same time and tzinfo.\n",
      "     |  \n",
      "     |  tzname(...)\n",
      "     |      Return self.tzinfo.tzname(self).\n",
      "     |  \n",
      "     |  utcoffset(...)\n",
      "     |      Return self.tzinfo.utcoffset(self).\n",
      "     |  \n",
      "     |  utctimetuple(...)\n",
      "     |      Return UTC time tuple, compatible with time.localtime().\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Class methods inherited from datetime.datetime:\n",
      "     |  \n",
      "     |  combine(...) from builtins.type\n",
      "     |      date, time -> datetime with same date and time fields\n",
      "     |  \n",
      "     |  fromisoformat(...) from builtins.type\n",
      "     |      string -> datetime from datetime.isoformat() output\n",
      "     |  \n",
      "     |  fromtimestamp(...) from builtins.type\n",
      "     |      timestamp[, tz] -> tz's local time from POSIX timestamp.\n",
      "     |  \n",
      "     |  now(tz=None) from builtins.type\n",
      "     |      Returns new datetime object representing current time local to tz.\n",
      "     |      \n",
      "     |        tz\n",
      "     |          Timezone object.\n",
      "     |      \n",
      "     |      If no tz is specified, uses local timezone.\n",
      "     |  \n",
      "     |  strptime(...) from builtins.type\n",
      "     |      string, format -> new datetime parsed from a string (like time.strptime()).\n",
      "     |  \n",
      "     |  utcfromtimestamp(...) from builtins.type\n",
      "     |      Construct a naive UTC datetime from a POSIX timestamp.\n",
      "     |  \n",
      "     |  utcnow(...) from builtins.type\n",
      "     |      Return a new datetime representing UTC day and time.\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Data descriptors inherited from datetime.datetime:\n",
      "     |  \n",
      "     |  fold\n",
      "     |  \n",
      "     |  hour\n",
      "     |  \n",
      "     |  microsecond\n",
      "     |  \n",
      "     |  minute\n",
      "     |  \n",
      "     |  second\n",
      "     |  \n",
      "     |  tzinfo\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Data and other attributes inherited from datetime.datetime:\n",
      "     |  \n",
      "     |  max = datetime.datetime(9999, 12, 31, 23, 59, 59, 999999)\n",
      "     |  \n",
      "     |  min = datetime.datetime(1, 1, 1, 0, 0)\n",
      "     |  \n",
      "     |  resolution = datetime.timedelta(microseconds=1)\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Methods inherited from datetime.date:\n",
      "     |  \n",
      "     |  __format__(...)\n",
      "     |      Formats self with strftime.\n",
      "     |  \n",
      "     |  isocalendar(...)\n",
      "     |      Return a 3-tuple containing ISO year, week number, and weekday.\n",
      "     |  \n",
      "     |  isoweekday(...)\n",
      "     |      Return the day of the week represented by the date.\n",
      "     |      Monday == 1 ... Sunday == 7\n",
      "     |  \n",
      "     |  strftime(...)\n",
      "     |      format -> strftime() style string.\n",
      "     |  \n",
      "     |  toordinal(...)\n",
      "     |      Return proleptic Gregorian ordinal.  January 1 of year 1 is day 1.\n",
      "     |  \n",
      "     |  weekday(...)\n",
      "     |      Return the day of the week represented by the date.\n",
      "     |      Monday == 0 ... Sunday == 6\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Class methods inherited from datetime.date:\n",
      "     |  \n",
      "     |  fromordinal(...) from builtins.type\n",
      "     |      int -> date corresponding to a proleptic Gregorian ordinal.\n",
      "     |  \n",
      "     |  today(...) from builtins.type\n",
      "     |      Current date or datetime:  same as self.__class__.fromtimestamp(time.time()).\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Data descriptors inherited from datetime.date:\n",
      "     |  \n",
      "     |  day\n",
      "     |  \n",
      "     |  month\n",
      "     |  \n",
      "     |  year\n",
      "    \n",
      "    class com_error(builtins.Exception)\n",
      "     |  com_error(*args, **kw)\n",
      "     |  \n",
      "     |  Common base class for all non-exit exceptions.\n",
      "     |  \n",
      "     |  Method resolution order:\n",
      "     |      com_error\n",
      "     |      builtins.Exception\n",
      "     |      builtins.BaseException\n",
      "     |      builtins.object\n",
      "     |  \n",
      "     |  Methods defined here:\n",
      "     |  \n",
      "     |  __init__(self, *args, **kw)\n",
      "     |      Initialize self.  See help(type(self)) for accurate signature.\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Data descriptors defined here:\n",
      "     |  \n",
      "     |  __weakref__\n",
      "     |      list of weak references to the object (if defined)\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Static methods inherited from builtins.Exception:\n",
      "     |  \n",
      "     |  __new__(*args, **kwargs) from builtins.type\n",
      "     |      Create and return a new object.  See help(type) for accurate signature.\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Methods inherited from builtins.BaseException:\n",
      "     |  \n",
      "     |  __delattr__(self, name, /)\n",
      "     |      Implement delattr(self, name).\n",
      "     |  \n",
      "     |  __getattribute__(self, name, /)\n",
      "     |      Return getattr(self, name).\n",
      "     |  \n",
      "     |  __reduce__(...)\n",
      "     |      Helper for pickle.\n",
      "     |  \n",
      "     |  __repr__(self, /)\n",
      "     |      Return repr(self).\n",
      "     |  \n",
      "     |  __setattr__(self, name, value, /)\n",
      "     |      Implement setattr(self, name, value).\n",
      "     |  \n",
      "     |  __setstate__(...)\n",
      "     |  \n",
      "     |  __str__(self, /)\n",
      "     |      Return str(self).\n",
      "     |  \n",
      "     |  with_traceback(...)\n",
      "     |      Exception.with_traceback(tb) --\n",
      "     |      set self.__traceback__ to tb and return self.\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Data descriptors inherited from builtins.BaseException:\n",
      "     |  \n",
      "     |  __cause__\n",
      "     |      exception cause\n",
      "     |  \n",
      "     |  __context__\n",
      "     |      exception context\n",
      "     |  \n",
      "     |  __dict__\n",
      "     |  \n",
      "     |  __suppress_context__\n",
      "     |  \n",
      "     |  __traceback__\n",
      "     |  \n",
      "     |  args\n",
      "    \n",
      "    class error(builtins.Exception)\n",
      "     |  error(*args, **kw)\n",
      "     |  \n",
      "     |  Common base class for all non-exit exceptions.\n",
      "     |  \n",
      "     |  Method resolution order:\n",
      "     |      error\n",
      "     |      builtins.Exception\n",
      "     |      builtins.BaseException\n",
      "     |      builtins.object\n",
      "     |  \n",
      "     |  Methods defined here:\n",
      "     |  \n",
      "     |  __init__(self, *args, **kw)\n",
      "     |      Initialize self.  See help(type(self)) for accurate signature.\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Data descriptors defined here:\n",
      "     |  \n",
      "     |  __weakref__\n",
      "     |      list of weak references to the object (if defined)\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Static methods inherited from builtins.Exception:\n",
      "     |  \n",
      "     |  __new__(*args, **kwargs) from builtins.type\n",
      "     |      Create and return a new object.  See help(type) for accurate signature.\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Methods inherited from builtins.BaseException:\n",
      "     |  \n",
      "     |  __delattr__(self, name, /)\n",
      "     |      Implement delattr(self, name).\n",
      "     |  \n",
      "     |  __getattribute__(self, name, /)\n",
      "     |      Return getattr(self, name).\n",
      "     |  \n",
      "     |  __reduce__(...)\n",
      "     |      Helper for pickle.\n",
      "     |  \n",
      "     |  __repr__(self, /)\n",
      "     |      Return repr(self).\n",
      "     |  \n",
      "     |  __setattr__(self, name, value, /)\n",
      "     |      Implement setattr(self, name, value).\n",
      "     |  \n",
      "     |  __setstate__(...)\n",
      "     |  \n",
      "     |  __str__(self, /)\n",
      "     |      Return str(self).\n",
      "     |  \n",
      "     |  with_traceback(...)\n",
      "     |      Exception.with_traceback(tb) --\n",
      "     |      set self.__traceback__ to tb and return self.\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Data descriptors inherited from builtins.BaseException:\n",
      "     |  \n",
      "     |  __cause__\n",
      "     |      exception cause\n",
      "     |  \n",
      "     |  __context__\n",
      "     |      exception context\n",
      "     |  \n",
      "     |  __dict__\n",
      "     |  \n",
      "     |  __suppress_context__\n",
      "     |  \n",
      "     |  __traceback__\n",
      "     |  \n",
      "     |  args\n",
      "\n",
      "FUNCTIONS\n",
      "    ACL(...)\n",
      "    \n",
      "    CreateGuid(...)\n",
      "    \n",
      "    DosDateTimeToTime(...)\n",
      "    \n",
      "    HANDLE(...)\n",
      "    \n",
      "    HKEY(...)\n",
      "    \n",
      "    IID(...)\n",
      "    \n",
      "    IsTextUnicode(...)\n",
      "    \n",
      "    OVERLAPPED(...)\n",
      "    \n",
      "    SECURITY_ATTRIBUTES(...)\n",
      "    \n",
      "    SECURITY_DESCRIPTOR(...)\n",
      "    \n",
      "    SID(...)\n",
      "    \n",
      "    Time(...)\n",
      "    \n",
      "    TimeStamp(...)\n",
      "    \n",
      "    Unicode(...)\n",
      "    \n",
      "    UnicodeFromRaw(...)\n",
      "    \n",
      "    WAVEFORMATEX(...)\n",
      "    \n",
      "    __import_pywin32_system_module__(modname, globs)\n",
      "\n",
      "DATA\n",
      "    FALSE = False\n",
      "    TRUE = True\n",
      "    WAVE_FORMAT_PCM = 1\n",
      "\n",
      "FILE\n",
      "    c:\\users\\alex\\anaconda3\\library\\bin\\pywintypes37.dll\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(pywintypes)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
